<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>ArNetworking: popupExample.cpp</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">ArNetworking
   &#160;<span id="projectnumber">dev20180125</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('popupExample_8cpp-example.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">popupExample.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<p>Shows how to create popup windows in a client like MobileEyesThis example server program connects to a robot, and sends a message to clients (e.g. MobileEyes) to display in a dialog box when a sensor reading is detected in front of the robot within 1 meter. It also checks to see if that obstacle is not at the same angle as the previous detected obstacle &ndash; it's probably the same one, unmoved &ndash; to avoid sending repeated popups. The popup offers three choices, acknowlege and do nothing, turn the robot around 180 degrees, or exit the server.</p>
<div class="fragment"><div class="line"></div><div class="line"><span class="preprocessor">#include &quot;Aria.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="ArNetworking_8h.html">ArNetworking.h</a>&quot;</span></div><div class="line"></div><div class="line"><span class="keyword">class </span><a name="_a0"></a><a class="code" href="classSensorDetectPopup.html">SensorDetectPopup</a></div><div class="line">{</div><div class="line"><span class="keyword">public</span>:</div><div class="line">  <a name="a1"></a><a class="code" href="classSensorDetectPopup.html#a176cae5018b13cc1fb2e727f74f0e242">SensorDetectPopup</a>(<a name="_a2"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArRobot.html">ArRobot</a> *robot, <a name="_a3"></a><a class="code" href="classArServerHandlerPopup.html">ArServerHandlerPopup</a> *popupServer);</div><div class="line"><span class="keyword">protected</span>:</div><div class="line">  <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArRobot.html">ArRobot</a> *<a name="a4"></a><a class="code" href="classSensorDetectPopup.html#a4f89ce29c0409c60a8ac10ba8fcceac8">myRobot</a>;</div><div class="line">  <a class="code" href="classArServerHandlerPopup.html">ArServerHandlerPopup</a> *<a name="a5"></a><a class="code" href="classSensorDetectPopup.html#ae9bb25dadda759e8c583ad197ea766ac">myPopupServer</a>;</div><div class="line">  <span class="keywordtype">bool</span> <a name="a6"></a><a class="code" href="classSensorDetectPopup.html#a153752cd67025b7e8f07c05c378fa475">myPopupDisplayed</a>;</div><div class="line">  <span class="keywordtype">double</span> <a name="a7"></a><a class="code" href="classSensorDetectPopup.html#a07cd92a62a7baf41d19f609b93de27cd">myPrevObstacleAngle</a>;</div><div class="line">  <span class="keywordtype">bool</span> <a name="a8"></a><a class="code" href="classSensorDetectPopup.html#af4f28ae8a03a9a940ee6078383b94f42">myPrevObstacleAngleValid</a>;</div><div class="line">  <a name="_a9"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArFunctor2C.html">ArFunctor2C&lt;SensorDetectPopup, ArTypes::Byte4, int&gt;</a> *<a name="a10"></a><a class="code" href="classSensorDetectPopup.html#af82c24053bb2115628bb16d2a7824ec4">myPopupClosedCB</a>;</div><div class="line"></div><div class="line">  <span class="keywordtype">void</span> <a name="a11"></a><a class="code" href="classSensorDetectPopup.html#ab94ccbef97b46bbd2bc173e9db30d306">popupClosed</a>(<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArTypes.html#aa9febccb890f2a2d72c3b88d2ab08855">ArTypes::Byte4</a> popupID, <span class="keywordtype">int</span> button);</div><div class="line">  <span class="keywordtype">void</span> <a name="a12"></a><a class="code" href="classSensorDetectPopup.html#aa85f6c8e45eeb576922151c67d4bbbf6">sensorTask</a>(<span class="keywordtype">void</span>)  ;</div><div class="line">};</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> <a name="a13"></a><a class="code" href="popupExample_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627">main</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)</div><div class="line">{</div><div class="line">  <a name="a14"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classAria.html#ad99c16b5d947229d9f8e1c5b2d4cdd73">Aria::init</a>();</div><div class="line">  <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArRobot.html">ArRobot</a> robot;</div><div class="line">  <a name="_a15"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArSonarDevice.html">ArSonarDevice</a> sonar;</div><div class="line">  <a name="_a16"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArSick.html">ArSick</a> sick;</div><div class="line">  robot.<a name="a17"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArRobot.html#a97d57b28549fdef851c00749a97cc776">addRangeDevice</a>(&amp;sonar);</div><div class="line">  <a name="_a18"></a><a class="code" href="classArServerBase.html">ArServerBase</a> server;</div><div class="line"></div><div class="line">  <span class="comment">// Argument parser:</span></div><div class="line">  <a name="_a19"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArArgumentParser.html">ArArgumentParser</a> parser(&amp;argc, argv);</div><div class="line">  parser.<a name="a20"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArArgumentParser.html#a501694b62a7f8b0c3cadd84aeafe1b35">loadDefaultArguments</a>();</div><div class="line"></div><div class="line">  <span class="comment">// Connector and server opener:</span></div><div class="line">  <a name="_a21"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArRobotConnector.html">ArRobotConnector</a> robotConnector(&amp;parser, &amp;robot);</div><div class="line">  <span class="keywordflow">if</span>(!robotConnector.<a name="a22"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArRobotConnector.html#ab192ac393d9cc1e5b61b1a82b08d085d">connectRobot</a>())</div><div class="line">  {</div><div class="line">    <a name="a23"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a name="a24"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, <span class="stringliteral">&quot;popupExample: Could not connect to the robot.&quot;</span>);</div><div class="line">    <span class="keywordflow">if</span>(parser.<a name="a25"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArArgumentParser.html#ac3889cbdfa862031c51bf80e06954914">checkHelpAndWarnUnparsed</a>())</div><div class="line">    {</div><div class="line">      <a name="a26"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classAria.html#a10d71f3d4d0cf7f38c58a1f749f64a42">Aria::logOptions</a>();</div><div class="line">    }</div><div class="line">    <a name="a27"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classAria.html#a6abc3d39b3e9548063bb8e78375acc17">Aria::exit</a>(1);</div><div class="line">  }</div><div class="line"></div><div class="line">  <a name="_a28"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLaserConnector.html">ArLaserConnector</a> laserConnector(&amp;parser, &amp;robot, &amp;robotConnector);</div><div class="line"></div><div class="line">  <a name="_a29"></a><a class="code" href="classArServerSimpleOpener.html">ArServerSimpleOpener</a> simpleOpener(&amp;parser);</div><div class="line"></div><div class="line">  <span class="comment">// Get command-line and other parameters</span></div><div class="line">  <span class="keywordflow">if</span>(!<a name="a30"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classAria.html#a1b090c01d88bb420b8cf8e0384d25ee1">Aria::parseArgs</a>() || !parser.<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArArgumentParser.html#ac3889cbdfa862031c51bf80e06954914">checkHelpAndWarnUnparsed</a>())</div><div class="line">  {</div><div class="line">    <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classAria.html#a10d71f3d4d0cf7f38c58a1f749f64a42">Aria::logOptions</a>();</div><div class="line">    <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classAria.html#a6abc3d39b3e9548063bb8e78375acc17">Aria::exit</a>(1);</div><div class="line">  }</div><div class="line"></div><div class="line">  robot.<a name="a31"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArRobot.html#a3c3d878cfd11a2ef91230005a83bfcaa">runAsync</a>(<span class="keyword">true</span>);</div><div class="line"></div><div class="line">  <span class="comment">// connect to the laser</span></div><div class="line">  <span class="keywordflow">if</span>(!laserConnector.<a name="a32"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLaserConnector.html#ab97ce6a5fedebf44526773bc674b970e">connectLasers</a>())</div><div class="line">  {</div><div class="line">    <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a name="a33"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;popupExample: Warning: Could not connect to lasers.&quot;</span>);</div><div class="line">  }</div><div class="line"></div><div class="line"></div><div class="line">  <span class="comment">// Open the server</span></div><div class="line">  <span class="keywordflow">if</span>(!simpleOpener.<a name="a34"></a><a class="code" href="classArServerSimpleOpener.html#a6429c1069dee5edc19fb7dc94078bed0">open</a>(&amp;server))</div><div class="line">  {</div><div class="line">    <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, <span class="stringliteral">&quot;popupExample: Error, could not open server.&quot;</span>);</div><div class="line">    <span class="keywordflow">return</span> 1;</div><div class="line">  }</div><div class="line">  server.<a name="a35"></a><a class="code" href="classArServerBase.html#a93c742ddc58a8f035a0d1b9c1fae4599">runAsync</a>();</div><div class="line">  <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;popupExample: Server running. Press control-C to exit.&quot;</span>);</div><div class="line">  <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;popupExample: Each time an obstacle is detected near the robot, a new popup message will be created. Connect with MobileEyes to see them.&quot;</span>);</div><div class="line"></div><div class="line">  <span class="comment">// Sends robot position etc.</span></div><div class="line">  <a name="_a36"></a><a class="code" href="classArServerInfoRobot.html">ArServerInfoRobot</a> robotInfoServer(&amp;server, &amp;robot);</div><div class="line"></div><div class="line">  <span class="comment">// This service sends drawings e.g. showing range device positions</span></div><div class="line">  <a name="_a37"></a><a class="code" href="classArServerInfoDrawings.html">ArServerInfoDrawings</a> drawingsServer(&amp;server);</div><div class="line">  drawingsServer.<a name="a38"></a><a class="code" href="classArServerInfoDrawings.html#afce43fb3fd0324b092600c9eb6fb50a7">addRobotsRangeDevices</a>(&amp;robot);</div><div class="line"></div><div class="line">  <span class="comment">// This service can send messages to clients to display as popup dialogs:</span></div><div class="line">  <a class="code" href="classArServerHandlerPopup.html">ArServerHandlerPopup</a> popupServer(&amp;server);</div><div class="line"></div><div class="line">  <span class="comment">// This object contains the robot sensor interpretation task and creates</span></div><div class="line">  <span class="comment">// popups:</span></div><div class="line">  <a class="code" href="classSensorDetectPopup.html#a176cae5018b13cc1fb2e727f74f0e242">SensorDetectPopup</a>(&amp;robot, &amp;popupServer);</div><div class="line"></div><div class="line">  <span class="comment">// modes for controlling robot movement</span></div><div class="line">  <a name="_a39"></a><a class="code" href="classArServerModeStop.html">ArServerModeStop</a> modeStop(&amp;server, &amp;robot);</div><div class="line">  <a name="_a40"></a><a class="code" href="classArServerModeRatioDrive.html">ArServerModeRatioDrive</a> modeRatioDrive(&amp;server, &amp;robot);  </div><div class="line">  <a name="_a41"></a><a class="code" href="classArServerModeWander.html">ArServerModeWander</a> modeWander(&amp;server, &amp;robot);</div><div class="line">  modeStop.<a name="a42"></a><a class="code" href="classArServerMode.html#ac071f8179603fecc38d69f8e89e88f34">addAsDefaultMode</a>();</div><div class="line">  modeStop.<a name="a43"></a><a class="code" href="classArServerModeStop.html#a701b1ae94cfda807e9f3d6c51a9fc53f">activate</a>();</div><div class="line"></div><div class="line">  <span class="comment">// allow configuration of driving and other settings</span></div><div class="line">  <a name="_a44"></a><a class="code" href="classArServerHandlerConfig.html">ArServerHandlerConfig</a> serverHandlerConfig(&amp;server, <a name="a45"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classAria.html#ace50b4190f04bcacaf285bb5830c5fc2">Aria::getConfig</a>()); <span class="comment">// make a config handler</span></div><div class="line">  <a name="a46"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#a830b6edab2079ae1ffeb7e164e30636b">ArLog::addToConfig</a>(<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classAria.html#ace50b4190f04bcacaf285bb5830c5fc2">Aria::getConfig</a>()); <span class="comment">// let people configure logging</span></div><div class="line"></div><div class="line">  modeRatioDrive.<a name="a47"></a><a class="code" href="classArServerModeRatioDrive.html#a5f9789a3e51ca3f52d3efbd7be5d4c66">addToConfig</a>(<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classAria.html#ace50b4190f04bcacaf285bb5830c5fc2">Aria::getConfig</a>(), <span class="stringliteral">&quot;Teleop settings&quot;</span>); <span class="comment">// able to configure teleop settings</span></div><div class="line"></div><div class="line">  robot.<a name="a48"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/group__easy.html#gaa3657bebab0086dd14ed0c8c3f76dc8b">enableMotors</a>();</div><div class="line">  robot.<a name="a49"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/group__easy.html#ga95201be7c39b521983b51e6f5d9303e4">waitForRunExit</a>();</div><div class="line"></div><div class="line">  <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classAria.html#a6abc3d39b3e9548063bb8e78375acc17">Aria::exit</a>(0);</div><div class="line">}</div><div class="line"></div><div class="line"><a class="code" href="classSensorDetectPopup.html#a176cae5018b13cc1fb2e727f74f0e242">SensorDetectPopup::SensorDetectPopup</a>(<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArRobot.html">ArRobot</a> *robot, <a class="code" href="classArServerHandlerPopup.html">ArServerHandlerPopup</a> *popupServer) :</div><div class="line">  <a class="code" href="classSensorDetectPopup.html#a4f89ce29c0409c60a8ac10ba8fcceac8">myRobot</a>(robot),</div><div class="line">  <a class="code" href="classSensorDetectPopup.html#ae9bb25dadda759e8c583ad197ea766ac">myPopupServer</a>(popupServer),</div><div class="line">  <a class="code" href="classSensorDetectPopup.html#a153752cd67025b7e8f07c05c378fa475">myPopupDisplayed</a>(<span class="keyword">false</span>),</div><div class="line">  <a class="code" href="classSensorDetectPopup.html#af4f28ae8a03a9a940ee6078383b94f42">myPrevObstacleAngleValid</a>(<span class="keyword">false</span>)</div><div class="line">{</div><div class="line"> <a class="code" href="classSensorDetectPopup.html#a4f89ce29c0409c60a8ac10ba8fcceac8">myRobot</a>-&gt;<a name="a50"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArRobot.html#a5aecc7ac998c9a31b82fdb904efa8609">lock</a>();</div><div class="line"> <a class="code" href="classSensorDetectPopup.html#a4f89ce29c0409c60a8ac10ba8fcceac8">myRobot</a>-&gt;<a name="a51"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArRobot.html#ab3ed1a09a96c009802ed64bbc6c75325">addSensorInterpTask</a>(<span class="stringliteral">&quot;sensorDetectPopup&quot;</span>, 50, <span class="keyword">new</span> <a name="_a52"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArFunctorC.html">ArFunctorC&lt;SensorDetectPopup&gt;</a>(<span class="keyword">this</span>, &amp;<a class="code" href="classSensorDetectPopup.html#aa85f6c8e45eeb576922151c67d4bbbf6">SensorDetectPopup::sensorTask</a>));</div><div class="line"> <a class="code" href="classSensorDetectPopup.html#af82c24053bb2115628bb16d2a7824ec4">myPopupClosedCB</a> = <span class="keyword">new</span> <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArFunctor2C.html">ArFunctor2C&lt;SensorDetectPopup, ArTypes::Byte4, int&gt;</a>(<span class="keyword">this</span>, &amp;<a class="code" href="classSensorDetectPopup.html#ab94ccbef97b46bbd2bc173e9db30d306">SensorDetectPopup::popupClosed</a>);</div><div class="line"> <a class="code" href="classSensorDetectPopup.html#a4f89ce29c0409c60a8ac10ba8fcceac8">myRobot</a>-&gt;<a name="a53"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArRobot.html#a403d9de010dc2b8d478cd0b14b2d9491">unlock</a>();</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> <a class="code" href="classSensorDetectPopup.html#aa85f6c8e45eeb576922151c67d4bbbf6">SensorDetectPopup::sensorTask</a>(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">  <span class="comment">// Basic obstacle detection</span></div><div class="line">  </div><div class="line">  <span class="keywordflow">if</span> (<a class="code" href="classSensorDetectPopup.html#a153752cd67025b7e8f07c05c378fa475">myPopupDisplayed</a>) <span class="keywordflow">return</span>;</div><div class="line">  <span class="keywordtype">double</span> detectAngle, detectRange;</div><div class="line">  detectRange = <a class="code" href="classSensorDetectPopup.html#a4f89ce29c0409c60a8ac10ba8fcceac8">myRobot</a>-&gt;<a name="a54"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArRobot.html#af022d2fe8078cd7f9dc82631e40fad13">checkRangeDevicesCurrentPolar</a>(-90, 90, &amp;detectAngle);</div><div class="line">  <span class="keywordflow">if</span> (detectRange &gt; 0 &amp;&amp; detectRange &lt;= 500)</div><div class="line">  {</div><div class="line">    <span class="keywordflow">if</span>(<a class="code" href="classSensorDetectPopup.html#af4f28ae8a03a9a940ee6078383b94f42">myPrevObstacleAngleValid</a> &amp;&amp; fabs(detectAngle - <a class="code" href="classSensorDetectPopup.html#a07cd92a62a7baf41d19f609b93de27cd">myPrevObstacleAngle</a>) &lt; 0.0001)</div><div class="line">      <span class="keywordflow">return</span>;</div><div class="line">    <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;popupExample: New obstacle detected at range %f, angle %f. Displaying popup dialog on client...&quot;</span>, detectRange, detectAngle);</div><div class="line"></div><div class="line">    <a name="_a55"></a><a class="code" href="classArServerHandlerPopupInfo.html">ArServerHandlerPopupInfo</a> info(<span class="stringliteral">&quot;popupExample&quot;</span>, <span class="comment">// ID</span></div><div class="line">              <span class="stringliteral">&quot;Object Detected&quot;</span>,                  <span class="comment">// Title</span></div><div class="line">              <span class="stringliteral">&quot;A range sensor detected a reading within 0.5 meters of the robot.&quot;</span>, <span class="comment">// Message</span></div><div class="line">              <a name="a56"></a><a class="code" href="classArServerHandlerPopup.html#af3fd6c866c5fd0ceecb8c74a0ab2a9a8ab99a3f402f6cff49cbc4bc7ad015e94c">ArServerHandlerPopup::INFORMATION</a>,  <span class="comment">// Type</span></div><div class="line">              0,                                  <span class="comment">// Default button</span></div><div class="line">              0,                                  <span class="comment">// Cancel/escape button</span></div><div class="line">              5,                                 <span class="comment">// Timeout (sec.)</span></div><div class="line">              NULL,                               <span class="comment">// Timeout String</span></div><div class="line">              <span class="stringliteral">&quot;OK&quot;</span>, <span class="stringliteral">&quot;Acknowleged.&quot;</span>,               <span class="comment">// Button 0 Label/Acknowlegement</span></div><div class="line">              <span class="stringliteral">&quot;Turn Around&quot;</span>, <span class="stringliteral">&quot;Requested rotate...&quot;</span>,   <span class="comment">// Button 1 Label/Acknowlegement</span></div><div class="line">              <span class="stringliteral">&quot;Shut Down&quot;</span>, <span class="stringliteral">&quot;Shutting down server...&quot;</span>  <span class="comment">// Button 2 Label/Acknowlegement</span></div><div class="line">             );</div><div class="line">    <span class="keywordtype">int</span> <span class="keywordtype">id</span> = <a class="code" href="classSensorDetectPopup.html#ae9bb25dadda759e8c583ad197ea766ac">myPopupServer</a>-&gt;<a name="a57"></a><a class="code" href="classArServerHandlerPopup.html#ab79890fae1963f6265408079728af806">createPopup</a>(&amp;info, <a class="code" href="classSensorDetectPopup.html#af82c24053bb2115628bb16d2a7824ec4">myPopupClosedCB</a>);</div><div class="line">    <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;\t...Created a popup with ID=%d&quot;</span>, <span class="keywordtype">id</span>);</div><div class="line">    <a class="code" href="classSensorDetectPopup.html#a153752cd67025b7e8f07c05c378fa475">myPopupDisplayed</a> = <span class="keyword">true</span>;</div><div class="line">    <a class="code" href="classSensorDetectPopup.html#a07cd92a62a7baf41d19f609b93de27cd">myPrevObstacleAngle</a> = detectAngle;</div><div class="line">    <a class="code" href="classSensorDetectPopup.html#af4f28ae8a03a9a940ee6078383b94f42">myPrevObstacleAngleValid</a> = <span class="keyword">true</span>;</div><div class="line">  }</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> <a class="code" href="classSensorDetectPopup.html#ab94ccbef97b46bbd2bc173e9db30d306">SensorDetectPopup::popupClosed</a>(<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArTypes.html#aa9febccb890f2a2d72c3b88d2ab08855">ArTypes::Byte4</a> popupID, <span class="keywordtype">int</span> button)</div><div class="line">{</div><div class="line">  <span class="comment">// A client closed the popup</span></div><div class="line">  <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;popupExample: a client closed popup dialog window with id=%d. Button=%d...&quot;</span>, popupID, button);</div><div class="line">  <a class="code" href="classSensorDetectPopup.html#a153752cd67025b7e8f07c05c378fa475">myPopupDisplayed</a> = <span class="keyword">false</span>;</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span>(button &lt; 0)</div><div class="line">  {</div><div class="line">    <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;\t...popup timed out or closed due to an error.&quot;</span>);</div><div class="line">    <span class="keywordflow">return</span>;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span> (button == 0)</div><div class="line">  {</div><div class="line">    <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;\t...OK pressed.&quot;</span>);</div><div class="line">    <span class="keywordflow">return</span>;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span>(button == 1)</div><div class="line">  {</div><div class="line">    <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;\t...180 degree rotate requested.&quot;</span>);</div><div class="line">    <a class="code" href="classSensorDetectPopup.html#a4f89ce29c0409c60a8ac10ba8fcceac8">myRobot</a>-&gt;<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArRobot.html#a5aecc7ac998c9a31b82fdb904efa8609">lock</a>();</div><div class="line">    <a class="code" href="classSensorDetectPopup.html#a4f89ce29c0409c60a8ac10ba8fcceac8">myRobot</a>-&gt;<a name="a58"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/group__easy.html#ga033038331dbe4cbaabad2d0bc67653f0">setDeltaHeading</a>(180);</div><div class="line">    <a class="code" href="classSensorDetectPopup.html#a4f89ce29c0409c60a8ac10ba8fcceac8">myRobot</a>-&gt;<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArRobot.html#a403d9de010dc2b8d478cd0b14b2d9491">unlock</a>();</div><div class="line">    <span class="keywordflow">return</span>;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span>(button == 2)</div><div class="line">  {</div><div class="line">    <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;\t...exit requested.&quot;</span>);</div><div class="line">    <a class="code" href="classSensorDetectPopup.html#a4f89ce29c0409c60a8ac10ba8fcceac8">myRobot</a>-&gt;<a name="a59"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/group__easy.html#gaff02cf7043c2e7239ec6b6e11ff6b146">stopRunning</a>();</div><div class="line">    <a name="a60"></a><a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classAria.html#a184602a2b3799d61569ec55dd9508450">Aria::shutdown</a>();</div><div class="line">    <a class="codeRef" doxygen="/home/reed/amrsw/Aria/docs/Aria.tag:../../docs/" href="../../docs/classAria.html#a6abc3d39b3e9548063bb8e78375acc17">Aria::exit</a>(0);</div><div class="line">  }</div><div class="line">}</div><div class="line"></div><div class="line"></div></div><!-- fragment --> </div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
  </ul>
</div>
</body>
</html>
